@extends('d.layout.index')
@section('con')
<div class="mws-panel grid_8">
 	<div class="mws-panel-header">
     	<span>商品款式尺寸添加</span>
     </div>

     <div class="mws-panel-body no-padding">
     	<form class="mws-form" action="/admin/goods/updatestyle" method="post" enctype="multipart/form-data">
               {{csrf_field()}}
               <input type="hidden" name="sid" value="{{$stylelist['id']}}">
               <input type="hidden" name="gid" value="{{$stylelist['gid']}}">
               <div style="margin-left:400px;padding-top:10px;color:blue">
                    <label class="mws-form-label">商品款式</label>          
               </div>                   
     		<div class="mws-form-inline">
     			<div class="mws-form-row">
     				<label class="mws-form-label">款式说明</label>
                         <div class="mws-form-item">
                              <input type="text" name='desc' class="small" value="{{$stylelist['desc']}}">
                         </div>
     			</div>    			
     		</div>
               <div class="mws-form-inline">
                    <div class="mws-form-row">
                         <label class="mws-form-label">款式图片</label>
                         <div class="mws-form-item">
                              <img src="/goods/pic/{{$stylelist['pic']}}" style="width:100px" alt=""><br>
                              <input type="file" name='pic' class="small" style="margin:2px">
                         </div>
                    </div>                   
               </div>
               <div style="margin-left:400px;padding-top:10px;color:blue">
                    <label class="mws-form-label">商品尺寸</label>          
               </div> 
               <div class="d" style="display:none">
                    <div class="mws-form-inline">
                         <div class="mws-form-row">
                              <label class="mws-form-label">商品尺寸</label>
                              <div class="mws-form-item">
                                   <input type="text" name='s0' class="small">
                              </div>
                         </div>                   
                    </div>
                    <div class="mws-form-inline">
                         <div class="mws-form-row">
                              <label class="mws-form-label">商品库存</label>
                              <div class="mws-form-item">
                                  <input type="text" name='s00' class="small">
                              </div>
                         </div>                   
                    </div>
               </div>
               @foreach($sizelist as $k => $v)
               <div class="d">
                    <div class="mws-form-inline">
                         <div class="mws-form-row">
                              <label class="mws-form-label">商品尺寸</label>
                              <div class="mws-form-item">
                                   <input type="text" name='size{{$k + 1}}' class="small" value="{{$v['size']}}">
                              </div>
                         </div>                   
                    </div>
                    <div class="mws-form-inline">
                         <div class="mws-form-row">
                              <label class="mws-form-label">商品库存</label>
                              <div class="mws-form-item">
                                  <input type="text" name='store_num{{$k + 1}}' class="small" value="{{$v['store_num']}}">
                              </div>
                         </div>                   
                    </div>
               </div>
               @endforeach
               <div class="mws-form-inline" id="s">
                    <div class="mws-form-row">
                         <button class="btn" id="btn" type="button">添加尺码</button>
                    </div>
               </div>
     		<div class="mws-button-row">
                    <button class="btn" id="goon">修改</button>
     			
     		</div>
     	</form>
     </div>    	
</div>
<script type="text/javascript" src="/d/js/libs/jquery-1.8.3.js"></script>
<script type="text/javascript">
     var num = $('input[class=small]:last').attr('name');
     num = Number(num.substr(-1,1)) + 1;

     $('#btn').click(function() {        
          var div = $('.d:first').clone();
          div.css('display','block');
          div.insertBefore($('#s'));
          div.find('input[name=s0]').attr('name','size'+num).val('');
          div.find('input[name=s00]').attr('name','store_num'+num).val('');
          num++;
          return false;
     });

     $('#goon').click(function() {
          var hidden = $('<input type="hidden" name="next" value="0" />');
          hidden.appendTo($('form'));
     });

     $('#end').click(function() {
          var hidden = $('<input type="hidden" name="next" value="1" />');
          hidden.appendTo($('form'));
     });
</script>
@endsection